// pages/emergency/emergency.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    "name1":"信息学部保卫部",
    "phone1":"12345678901",
    "name2":"信息学部派出所",
    "phone2":"12345678902",
    "name3":"武汉大学动小保",
    "phone3":"12345678903",
    "emerphone1":"12345678904",
    "emerphone2":"12345678905",
    "message":[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        selected: 3
      })
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  wakephone(e){
    let id=e.currentTarget.dataset.id
    let phone=this.data.phone1
    switch(id){
      case "1": 
        phone=this.data.phone1
        break
      case "2":
        phone=this.data.phone2
        break
      case "3":
        phone=this.data.phone3
        break
      case "4":
        phone=this.data.emerphone1
        break
      case "5":
        phone=this.data.emerphone2
        break
    }
    let that=this;
    wx.makePhoneCall({
      phoneNumber: phone
    }).catch((e)=>{
      console.log(e)
    })
  },
  sendmessage(){
    var header={};
    header = { 
      'content-type': 'application/x-www-form-urlencoded'
    };
    var cookie = wx.getStorageSync("cookieKey");
    header['cookie'] = cookie;

    wx.request({
      url: 'http://localhost:8080/consult/test',
      header:header,
      method:"POST",
      data:({
        "id":1
      })
    })
  }
})
